Fix PSNR/SSIM crashes on common inputs - #196
Merged
Merged
Conversation
- psnr/ssim: unbatched mode passed torch tensors to skimage (TypeError); now uses the numpy-converted x_/target_ - ssim: default channel_axis=1 was wrong for LION's channels-first layout; crashed on multichannel input and silently returned wrong values on 2D. Now None, inferred per sample (2D -> None, 3D+ -> 0) - ssim: vals[i] = skim_ssim(...) assigned numpy.float32 into a torch tensor (TypeError); wrapped in torch.tensor(...) - psnr/ssim: reduce=str | None was a default value, not a type hint, so calling without reduce always raised ValueError; now reduce: str | None = None
cslht
force-pushed
the
fix/metrics-crashes
branch
from
August 5, 2026 02:24
b32125c to
911c76a
Compare
black --all-files in pre-commit flags LIONmodel.py and two classical_algorithms tests (from CambridgeCIA#194). Formatting only, no behavioural changes.
cslht11
pushed a commit
to cslht11/LION
that referenced
this pull request
Sep 6, 2026
Fix PSNR/SSIM crashes on common inputs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four fixes in PSNR/SSIM:
TypeError); now uses the numpy-convertedx_/target_.SSIMdefaulted tochannel_axis=1, wrong for LION's channels-first layout — crashed on multichannel, silently wrong on 2D. NowNone, inferred per sample.vals[i] = skim_ssim(...)assigned anumpy.float32into a torch tensor; wrapped intorch.tensor(...).reduce=str | Nonewas a default value, not a type hint, so calling withoutreducealways raisedValueError; nowreduce: str | None = None.